package com.atguigu.imperial.court.controller;

import com.atguigu.imperial.court.court.entity.Emp;
import com.atguigu.imperial.court.service.api.EmpService;
import com.atguigu.imperial.court.court.util.ResultEntity;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: EmpController
 * Description:
 * Date: 2022/09/20 PM 11:33
 * <p>
 * project: pro07-demo-imperial-court-micro-service
 * package: com.atguigu.imperial.controller
 * email: 1085844536@qq.com
 * version:
 *
 * @author WangGuojian
 */
@RestController
public class EmpController {
    @Autowired
    private EmpService empService;

    @RequestMapping("remote/get/emp/by/login/info")
    ResultEntity<Emp> getEmpByLoginInfo(
            @RequestParam("loginAccount") String loginAccount,
            @RequestParam("loginPassword") String loginPassword) {
        try {
            Emp emp = empService.getEmpByLoginInfo(loginAccount,
                    loginPassword);
            return ResultEntity.successWithData(emp);
        } catch (Exception e) {
            e.printStackTrace();
            String message = e.getMessage();
            return ResultEntity.failed(message);
        }
    }
}
